package com.zygame.sdk.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.zygame.sdk.ConstantValue;



public class SharedPreferencesHelper {
	
	private static SharedPreferencesHelper instance;
	private static byte[] lock = new byte[0];
	
	private SharedPreferencesHelper() {	}
	
	public static SharedPreferencesHelper getInstance() {
		if (instance == null) {
			synchronized (lock) {
				if (instance == null) {
					instance = new SharedPreferencesHelper();
				}
			}
		}
		return instance;
	}
	
	public SharedPreferences getSharedPreferences(Context context){
		return context.getSharedPreferences(ConstantValue.SharedPreferences._65_SHAREDPREFERENCESFILE,Context.MODE_PRIVATE);
	}
	
	
	/**
	 * 保存电话号码和验证码     15920326347-17324
	 * @param context
	 * @param str
	 */
    public void setPhoneAndCode(Context context,String str){
    	SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_PHONE_CODE, Context.MODE_PRIVATE);
        sharedPreferences.edit().putString(ConstantValue.SharedPreferences.CONFIG_PHONE_CODE_FLAG, str).commit();
    }
    
    public String getPhoneAndCode(Context context){
    	SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_PHONE_CODE, Context.MODE_PRIVATE);
    	return sharedPreferences.getString(ConstantValue.SharedPreferences.CONFIG_PHONE_CODE_FLAG, "");
    }
    
    /**
     * 设置消息提示数量
     * @param context
     * @param str
     */
    public void setMsgPromptAmount(Context context,int amount){
    	SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_MSG_PROMPT_AMOUNT, Context.MODE_PRIVATE);
        sharedPreferences.edit().putInt(ConstantValue.SharedPreferences.CONFIG_MSG_PROMPT_AMOUNT_FLAG, amount).commit();
    }
    
    public int getMsgPromptAmount(Context context){
    	SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_MSG_PROMPT_AMOUNT, Context.MODE_PRIVATE);
    	return sharedPreferences.getInt(ConstantValue.SharedPreferences.CONFIG_MSG_PROMPT_AMOUNT_FLAG, 1);   //默认设置有1条消息
    }
	public void setLogin_Token(Context context,String loginToken){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.LOGIN_TOKEN, loginToken).commit();
	}

	public String getLogin_Token(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.LOGIN_TOKEN, "");
	}


	public void setToken(Context context,String token){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.TOKEN, token).commit();
	}

	public String getToken(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.TOKEN, "");
	}


	public void setGameJson(Context context,String gameJson){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.GAME_JSON, gameJson).commit();
	}

	public String getGameJson(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.GAME_JSON, "");
	}
	public void setPayUrl(Context context,String payurl){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.PAYURL, payurl).commit();
	}

	public String getPayUrl(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.PAYURL, "");
	}
	public void setSid(Context context,String sid){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.ZY_SID, sid).commit();
	}

	public String getSid(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.ZY_SID, "");
	}
	public void setToolBar(Context context,String is_tool_bar){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.ZY_ToolBar, is_tool_bar).commit();
	}

	public String getToolBar(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.ZY_ToolBar, "");
	}
	public void setGMail(Context context,String gmail){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.ZY_GMAIL, gmail).commit();
	}

	public String getZY_GMAIL(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.ZY_GMAIL, "");
	}
	public void setWechat(Context context,String wechat){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		sharedPreferences.edit().putString(ConstantValue.SharedPreferences.ZY_WECHAT, wechat).commit();
	}

	public String getWechat(Context context){
		SharedPreferences sharedPreferences = context.getSharedPreferences(ConstantValue.SharedPreferences.CONFIG_TOKENINFO, Context.MODE_PRIVATE);
		return sharedPreferences.getString(ConstantValue.SharedPreferences.ZY_WECHAT, "");
	}



}
